package com.power.controller.DefectAd;

import com.alibaba.fastjson.JSONObject;

import com.power.common.Contants;
import com.power.dao.impl.DefectAdDaoImpl;
import com.power.ov.ResultData;
import com.power.pojo.Defecttype;
import com.power.pojo.Users;
import com.power.service.DefectAdService;
import com.power.service.impl.defectAdServiceImpl;
import com.power.utils.WriterUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.sql.SQLException;

/**
 * Created/**
 * Created with IntelliJ IDEA.
 * User: lh
 * Date: 2020/09/29 21:01
 * Description:修改缺陷类型
 * Version: V1.0
 */

@WebServlet("/updateType.do")
public class UpdateServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        BufferedReader br=req.getReader();
        String string=br.readLine();
        Defecttype defecttype= JSONObject.parseObject(string,Defecttype.class);
        DefectAdService defectAdService=new defectAdServiceImpl();
        ResultData resultData=new ResultData();
        try {
            resultData=defectAdService.updateDefecttype(defecttype);
        } catch (SQLException e) {
            resp.setContentType("application/json;charset=utf-8");
            resultData.setCode(Contants.EXCEPTION);
            resultData.setMsg("系统开小差了...");
            e.printStackTrace();
        }
        System.out.println(resultData);
        WriterUtil.getWriter(resp,resultData);
    }
}
